﻿using AutoMapper;
using Face8280WebSocketServer.Command.Models;
using Face8280WebSocketServer.Command.WorkParameter;
using FaceFace8280WebSocketServer.Controllers.New.FaceDevice;
using Newtonsoft.Json.Serialization;

namespace FaceFace8280WebSocketServer
{
    public class AutoMapperConfigs : Profile
    {
        public AutoMapperConfigs()
        {

            InitDeviceConfigs();
            InitNetWorkConfigs();
        }

        public void InitDeviceConfigs()
        {
            //CreateMap<MakerModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<WgOutputModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<WorkStatus, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<OpenTimeoutAlarm, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<PeopleStorageDetails, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<RecordStorageDetails, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<DevcieVersion, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<RepeatModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<SensorAlarmModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<BodyTmp, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<GetWorkParam_DTO, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>();
            //CreateMap<Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceDetailNew>()
            //    .ForMember(dest => dest.Id, opt => opt.Ignore());//忽略属性

            CreateMap<GetWorkParam_DTO, GetDeviceDetailDTO>();

            CreateMap<MakerModel, GetDeviceDetailDTO>()
                .ForMember(dest => dest.Name, opt => opt.Ignore())
                .ForMember(dest => dest.MakerName, opt => opt.MapFrom(src => src.Name))
                .ForMember(dest => dest.MakerUrl, opt => opt.MapFrom(src => src.Url))
                .ForMember(dest => dest.MakerDate, opt => opt.MapFrom(src => src.Date));//定义映射规则;

            CreateMap<WgOutputModel, GetDeviceDetailDTO>()
                 .ForMember(dest => dest.WGUse, opt => opt.MapFrom(src => src.Use))
                 // .ForMember(dest => dest.WGBits, opt => opt.MapFrom(src => src.Bits))
                 .ForMember(dest => dest.WGOrder, opt => opt.MapFrom(src => src.Order))
                 .ForMember(dest => dest.WGType, opt => opt.MapFrom(src => src.Type));

            CreateMap<WorkStatus, GetDeviceDetailDTO>()
                .ForMember(dest => dest.WSUps, opt => opt.MapFrom(src => src.Ups))
                .ForMember(dest => dest.WSVoltage, opt => opt.MapFrom(src => src.Voltage))
                .ForMember(dest => dest.WSTemperature, opt => opt.MapFrom(src => src.Temperature))
                .ForMember(dest => dest.WSRelay, opt => opt.MapFrom(src => src.Relay))
                .ForMember(dest => dest.WSKeepopen, opt => opt.MapFrom(src => src.Keepopen))
                .ForMember(dest => dest.WSDoorSensor, opt => opt.MapFrom(src => src.DoorSensor))
                .ForMember(dest => dest.WSLockSensor, opt => opt.MapFrom(src => src.LockSensor))
                .ForMember(dest => dest.WSLocked, opt => opt.MapFrom(src => src.Locked))
                .ForMember(dest => dest.WSMsgPush, opt => opt.MapFrom(src => src.MsgPush))
                .ForMember(dest => dest.WSAlarm, opt => opt.MapFrom(src => src.Alarm));

            CreateMap<OpenTimeoutAlarm, GetDeviceDetailDTO>()
                .ForMember(dest => dest.OTAUse, opt => opt.MapFrom(src => src.Use))
                .ForMember(dest => dest.OTATimeout, opt => opt.MapFrom(src => src.Timeout))
                .ForMember(dest => dest.OTAAlarm, opt => opt.MapFrom(src => src.Alarm));

            CreateMap<PeopleStorageDetails, GetDeviceDetailDTO>()
                .ForMember(dest => dest.PSPerson, opt => opt.MapFrom(src => src.Person))
                .ForMember(dest => dest.PSFace, opt => opt.MapFrom(src => src.Face))
                .ForMember(dest => dest.PSCard, opt => opt.MapFrom(src => src.Card))
                .ForMember(dest => dest.PSFP, opt => opt.MapFrom(src => src.FP))
                .ForMember(dest => dest.PSPasword, opt => opt.MapFrom(src => src.Pasword))
                .ForMember(dest => dest.PSAdmin, opt => opt.MapFrom(src => src.Admin));

            CreateMap<RecordStorageDetails, GetDeviceDetailDTO>()
                .ForMember(dest => dest.Door, opt => opt.Ignore())
                .ForMember(dest => dest.RSRecord, opt => opt.MapFrom(src => src.Record))
                .ForMember(dest => dest.RSSystem, opt => opt.MapFrom(src => src.System))
                .ForMember(dest => dest.RSAlarm, opt => opt.MapFrom(src => src.Alarm))
                .ForMember(dest => dest.RSDoor, opt => opt.MapFrom(src => src.Door));

            CreateMap<DevcieVersion, GetDeviceDetailDTO>()
                .ForMember(dest => dest.VVer, opt => opt.MapFrom(src => src.ver))
                .ForMember(dest => dest.VFace, opt => opt.MapFrom(src => src.face))
                .ForMember(dest => dest.VFp, opt => opt.MapFrom(src => src.fp));


            CreateMap<RepeatModel, GetDeviceDetailDTO>()
                .ForMember(dest => dest.RpUse, opt => opt.MapFrom(src => src.Use))
                .ForMember(dest => dest.RpMode, opt => opt.MapFrom(src => src.Mode))
                .ForMember(dest => dest.RpInterval, opt => opt.MapFrom(src => src.Interval));

            CreateMap<SensorAlarmModel, GetDeviceDetailDTO>()
                 .ForMember(dest => dest.Time, opt => opt.Ignore())
                .ForMember(dest => dest.SAUse, opt => opt.MapFrom(src => src.Use))
                .ForMember(dest => dest.SATime, opt => opt.MapFrom(src => src.Time));

            CreateMap<BodyTmpModel, GetDeviceDetailDTO>()
                .ForMember(dest => dest.BTUse, opt => opt.MapFrom(src => src.Use))
                .ForMember(dest => dest.BTFormat, opt => opt.MapFrom(src => src.Format))
                .ForMember(dest => dest.BTAlarm, opt => opt.MapFrom(src => src.Alarm))
                .ForMember(dest => dest.BTShow, opt => opt.MapFrom(src => src.Show))
                .ForMember(dest => dest.BTCompensate, opt => opt.MapFrom(src => src.Compensate));

            CreateMap<IpModel, GetDeviceDetailDTO>()
                .ForMember(dest => dest.IIp, opt => opt.MapFrom(src => src.Ip))
                .ForMember(dest => dest.IMask, opt => opt.MapFrom(src => src.Mask))
                .ForMember(dest => dest.IMac, opt => opt.MapFrom(src => src.Mac))
                .ForMember(dest => dest.IGateway, opt => opt.MapFrom(src => src.Gateway))
                .ForMember(dest => dest.IDhcp, opt => opt.MapFrom(src => src.Dhcp))
                .ForMember(dest => dest.IDns, opt => opt.MapFrom(src => src.Dns))
                .ForMember(dest => dest.IUdp, opt => opt.MapFrom(src => src.Udp))
                .ForMember(dest => dest.ITcp, opt => opt.MapFrom(src => src.Tcp))
                .ForMember(dest => dest.IWebsocket, opt => opt.MapFrom(src => src.Websocket))
                .ForMember(dest => dest.ISsl, opt => opt.MapFrom(src => src.Ssl))
                ;

            CreateMap<WebsocketServerModel, GetDeviceDetailDTO>()
                .ForMember(dest => dest.WSServer, opt => opt.MapFrom(src => src.Server))
                .ForMember(dest => dest.WSPort, opt => opt.MapFrom(src => src.Port))
                .ForMember(dest => dest.WSToken, opt => opt.MapFrom(src => src.Token))
                .ForMember(dest => dest.WSServerSSLCert, opt => opt.MapFrom(src => src.ServerSSLCert))
                .ForMember(dest => dest.WSStatus, opt => opt.MapFrom(src => src.Status))
                .ForMember(dest => dest.WSKeepalive, opt => opt.MapFrom(src => src.Keepalive))
                .ForMember(dest => dest.WSKeeptime, opt => opt.MapFrom(src => src.Keeptime))
                .ForMember(dest => dest.WSReconnectTime, opt => opt.MapFrom(src => src.ReconnectTime));

            CreateMap<WiFiModel, GetDeviceDetailDTO>()
                .ForMember(dest => dest.WiFiUse, opt => opt.MapFrom(src => src.Use))
                .ForMember(dest => dest.WiFiName, opt => opt.MapFrom(src => src.Name))
                .ForMember(dest => dest.WiFiPassword, opt => opt.MapFrom(src => src.Password));
            CreateMap<Face8280WebSocketServer.DB.Device.FaceDeviceInfo, Face8280WebSocketServer.DTO.FaceDevice.UpdateDeviceDetailParameter>()
                .ForMember(dest => dest.Id, opt => opt.Ignore());//忽略属性;
            CreateMap<Face8280WebSocketServer.DB.Device.FaceDeviceInfo, Face8280WebSocketServer.DB.Device.FaceDeviceInfo>()
                .ForMember(dest => dest.Id, opt => opt.Ignore());//忽略属性;
        }

        public void InitNetWorkConfigs()
        {
            //CreateMap<IpModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceNetWork>();
            //CreateMap<WebsocketServerModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceNetWork>();
            //CreateMap<WiFiModel, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceNetWork>();
            //CreateMap<Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceNetWork, Face8280WebSocketServer.DB.NewModel.Device.FaceDeviceNetWork>()
            //     .ForMember(dest => dest.Id, opt => opt.Ignore());//忽略属性;
        }
    }
}
